<!-- 引体向上 -->
<template>
	<view class="container" >
		<view class='one'  v-if="ifpoll" >	
		   <image  
		   class="img"
		  
			src="../../static/mode1_exec.png"  
			></image>
			
			<view class="information">
				<view>考生姓名：{{name}}</view>
				<view>成绩：{{num}}</view>
			</view>
	    </view>
		
		<view class='one' 
		v-if="!ifpoll">
		   <image  
		   class="img"
		   
			src="../../static/mode2_exec.png"  
			></image>
			
			<view class="information">
				<view>考生姓名：{{name}}</view>
				<view>成绩：{{num}}</view>
			</view>
		</view>
    
		 
		 <view class="end">
			 <button class='end_btn' type="primary" @click='end_test'>结束体测</button>
			 
		 </view>
	</view>
	
</template>

<script>
	
	export default {
		data() {
			return {
				name:"",
				num:null,
				mode:null,
				timer:null,
				ifpoll:false,
	 
			}
		},
		onLoad(res){
			let that=this
			this.mode=res.mode
			if(res.mode==1){
				this.ifpoll=true
			}else if(res.mode==3){
				this.ifpoll=false
			}
			this.getTest()
			this.timer = setInterval(() => {
			 this.getTest()
			  console.log('定时器触发');
			}, 200);  // 2秒后执行
			
			
		},
		methods: {
			async getTest(){
				let that=this
				await this.$myRequest("/frontend/realtime?uuid=706655b1367b","POST",{}).then(resp=>{
					if(resp.data.list.equip1.have_person==true){
						that.name=resp.data.list.equip1.stu_name
						that.num=resp.data.list.equip1.value
					}
				
				});
				
			},
			async end_test(){
				let that=this
				await this.$myRequest("/frontend/realtime?uuid=706655b1367b","POST",{}).then(resp=>{
					clearInterval(that.timer)
					uni.navigateTo({
						url:"/pages/index/home"
					})
				
				});
				
			},
			
		}
	}
</script>

<style>
.container{
	display:flex;
	flex-direction: column;
	text-align: center;
	box-sizing: border-box;
	justify-content:center;
	align-items: center;
	width:100%;
	height:100%;
}
.one{
	display:flex;
	flex-direction: column;
	justify-content:center;
	align-items: center;
	text-align: center;
	width:100%;
	height:50%;
	z-index:1;
}

.information{
	position:absolute;
	z-index:2;
    display:flex;
	left:50%;
	top:40%;
	flex-direction: column;
	justify-content:center;
	align-items: left;
	font-size:20px;
	line-height: 100rpx;
	text-align: left;
}
.img{
	width:80%;
	height:70%;
}
.end{
	z-index:1;
	width:80%;
	display:flex;
	flex-direction: column;
	justify-content: left;
	align-items: flex-end;
}
.end_btn{
	width:90%;
}

</style>
